import Vue from 'vue'
//写路由
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//路由地址
const routes = [
    {
        path: '/',
        redirect: '/layout'
    },
    {
        path: '/login',
        component: () => import('../view/login.vue')
    },
    {
        path: '/layout',
        component: () => import('../view/layout.vue'),
        redirect: "/layout/index",
        children: [
            {
                path: 'index',
                component: () => import('../view/index.vue')
            }, {
                path: 'search',
                component: () => import('../view/search.vue')
            },
            {
                path: 'personal',
                component: () => import('../view/personal.vue')
            },
        ]
    },
    {
        path: '/citylist',
        component: () => import('../view/citylist.vue')
    },
    {
        path: '/details',
        component: () => import('../view/details.vue')
    },
    {
        path: '/categoryList',
        component: () => import('../view/categoryList.vue')
    },
    {
        path:'/shopping',
        component: ()=>import('../view/shopping.vue')
    },{
        path:'/shopDetails',
        component:()=>import('../view/shopDetails.vue')
    },{
        path:'/merchant',
        component:()=>import('../view/merchant.vue')
    }
]

//解决跳转到同一个页面,vue报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}


const router = new VueRouter({ routes })

export default router
